home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / UGetMultipleFiles 1.4 / UGetMultipleFiles.h < prev    next >
Encoding:
Text File  |  1997-07-24  |  4.4 KB  |  101 lines  |  [TEXT/CWIE]

  1. // --------------------------------------------------------------------------------------------
  2. //    UGetMulltipleFiles - An Add Files utility class
  3. //        By David Hirsch
  4. // --------------------------------------------------------------------------------------------
  5.  
  6. #pragma once
  7. #include "LFSSpecArrayComp.h"
  8.  
  9. // --------------------------------------------------------------------------------------------
  10. //    Items in the custom dialog box.
  11. // --------------------------------------------------------------------------------------------
  12. const ResIDT    kDLOG_OpenMultiple        = 900;
  13. const ResIDT    kStdButton_Add            = 1;
  14. const ResIDT    kDesktopButton            = 6;
  15. const ResIDT    kUserItem_FileList        = 7;
  16. const ResIDT    kStaticText_Prompt        = 10;
  17. const ResIDT    kUserItem_AddedList        = 11;
  18. const ResIDT    kStdButton_Done            = 12;
  19. const ResIDT    kStdButton_Remove        = 13;
  20. const ResIDT    kStdButton_AddAll        = 15;
  21. const ResIDT    kPict_DividerLine        = 14;
  22. const ResIDT    kStdButton_RemoveAll    = 16;
  23. const ResIDT    kStdButton_Select        = 17;
  24. const short        kHome                    = 1;
  25. const short        kEnd                    = 4;
  26. const short        kUpArrow                = 30;
  27. const short        kDownArrow                = 31;
  28. const short        kPageUp                    = 11;
  29. const short        kPageDown                = 12;
  30. const short        kUpArrowPlusCO            = kUpArrow + sfHookCharOffset;
  31. const short        kDownArrowPlusCO        = kDownArrow + sfHookCharOffset;
  32.  
  33. const ResIDT    kSTR_List                = 900;
  34. const ResIDT    kSTR_SelectItem            = 1;
  35. const Str255    kFolderButtonRoot        = "\pAdd \"";
  36.  
  37. const    short    kMaxNumFilesToFind = 20;        // number of files to examine at a time
  38. const    short    kNumAddedCellsVisible = 5;        // number of cells that are visible in the added
  39.                                                 // file list at once
  40.  
  41.  
  42. struct dataHolderType {
  43.     short    whichFocused;
  44. };
  45.  
  46. class UGetMultipleFiles {
  47.     public:
  48.         enum { err_otherGetDirErr =    'oGDE' };
  49.                                     UGetMultipleFiles();
  50.                                     UGetMultipleFiles(Str255 prompt, short numTypes = 0, SFTypeList typeList = nil,
  51.                                                     LArray *inFileList = nil, Boolean inAllowConversion = true,
  52.                                                     Boolean inShowFolders = true, Boolean inAddFolders = false);
  53.                                     ~UGetMultipleFiles();
  54.         static LArray                *GetFSSpecs();
  55.         static StandardFileReply    GetSFReply();
  56.     private:    // member functions
  57.         static pascal Boolean        myModalFilter (DialogPtr theDialogP, EventRecord *event,
  58.                                                  short *itemHit, void *myUnused);
  59.         static pascal short            myDialogHook (short item, DialogPtr theDialogP, void *myUnused);
  60.         static pascal Boolean        myFileFilter (CInfoPBPtr pb, void *ioParam);
  61.         static pascal void            myActivateProc (DialogPtr theDialogP, short itemNum,
  62.                                                  Boolean activating, void *ioParam);
  63.         static pascal void            MyDrawListItem (WindowPtr theWindow, short item);
  64.         static void                    AddOneToList(Str255 , long , short);
  65.         static void                    AddAllToList(Boolean atDesktop);
  66.         static void                    RemoveAllFromList();
  67.         static void                    RemoveFromList();
  68.         static long                    GetSFCurDir(void);
  69.         static short                GetSFVRefNum(void);
  70.         static ListHandle            MyCreateTextListInDialog (DialogPtr , short );
  71.         static ListHandle            MyCreateVerticallyScrollingList (WindowPtr , Rect , short , short );
  72.         static void                    SetEnable(ResIDT theItem, Boolean enabled);
  73.         static Boolean                GetEnabled(ResIDT theItem);
  74.         static void                    ReplaceString ( Str255 destStr, Str255 whatStr, Str255 byStr ); 
  75.         static Boolean                 TypeInList( OSType inType );
  76.         static void                    SetCurrentVolume(short vRefNum);
  77.         static void                    SetCurrentDirectory(long dirID);
  78.         static void                    FixButtons (DialogPtr theDialogP, void *ioParam);
  79.         static void                    SetButtonTitle (Handle ButtonHdl, Str255 name, Rect ButtonRect);
  80.         static void                    DoListKey(short theKey, ListHandle theListH);
  81.         static Boolean                 IsFile(FSSpec inFile);
  82.         static OSErr                GetCatInfoNoName(short vRefNum, long dirID, ConstStr255Param name, CInfoPBPtr pb);
  83.         static void                 EnsureSelection(short inActiveList);
  84.         static inline Boolean        IsFolder(CInfoPBPtr pb) {return (pb->hFileInfo.ioFlAttrib & 0x10);};
  85.  
  86.     private:    // data members
  87.         static ListHandle            sAddedListH;
  88.         static DialogPtr            sDialogP;
  89.         static StandardFileReply    sReply;
  90.         static LArray                *sTheFSpecs;
  91.         static LArray                *sNixFiles;
  92.         static LFSSpecArrayComp        *sComparatorP;
  93.         static short                sNumTypes;
  94.         static SFTypeList            sTypeList;
  95.         static Boolean                sNeedToRebuild;
  96.         static Boolean                sShowFolders;
  97.         static Boolean                sAddFolders;
  98.         static Boolean                 sAllowConversion;        // Allow MEO to convert the File,
  99.                                                         // allow checking for locked files, etc. 
  100.         static short                sKeyPressed;
  101. };